#!/usr/bin/env node

const Router = require('koa-router'),
  admin = require('../models/admin_mod'),
  // jwt = require('jsonwebtoken'),
  // {JWT_KEY} = require('../lib/constant.js'),
  // _ = require('lodash'),
  router = new Router;
router.prefix('/api/admin');


router.get('/', async (ctx, next) => {
  // let {email,password} = ctx.request.body;
  let res = await admin.Admin_gets();

  ctx.body = res;
})

router.post('/slg', async (ctx, next) => {
  let { admin_phone, admin_password, time } = ctx.request.body;
  let res = await admin.Admin_get_slg(admin_phone, admin_password, time);

  ctx.body = res;
})
router.post('/', async (ctx, next) => {
  let { admin_id, password, admin_name, admin_position, admin_phone, admin_email, admin_password, password_confim } = ctx.request.body;
  let res = await admin.Admin_create(admin_id, password, admin_name, admin_position, admin_phone, admin_email, admin_password, password_confim);
  ctx.body = res;
})
router.delete('/', async (ctx, next) => {
  let { admin_id, admin_id2, admin_password } = ctx.request.body;
  let res = await admin.Admin_delete(admin_id, admin_id2, admin_password);
  ctx.body = res;
})
router.post('/create', async (ctx, next) => {
  let { admin_id, password, admin_name, admin_position, admin_phone, admin_email, admin_password, password_confim } = ctx.request.body;
  let res = await admin.Admin_create(admin_id, password, admin_name, admin_position, admin_phone, admin_email, admin_password, password_confim);
  ctx.body = res;
})
module.exports = router;
